package com.huawei.appgallery.agwebview.choosefile;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import com.huawei.appgallery.common.media.api.IMediaSelectProtocol;
import com.huawei.appgallery.common.media.api.IMediaSelectResult;
import com.huawei.appgallery.foundation.ui.framework.activity.AbstractBaseActivity;
import com.huawei.secure.android.common.intent.SafeIntent;
import java.util.List;
import o.azf.c;
import o.azh;
import o.baf;
import o.dof;
import o.fho;
import o.fiu;
import o.fjb;
import o.fjc;

public class WebViewTransferActivity extends AbstractBaseActivity {
    private boolean ˊॱ = false;
    private String ˋॱ = null;
    private boolean ˏॱ = false;
    private int ॱˊ = 1;

    public void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        bundle.putBoolean("has_start_selected", this.ˏॱ);
    }

    public void onCreate(Bundle bundle) {
        azh.ˏ.ˎ("WebViewTransferActivity", "onCreate");
        requestWindowFeature(1);
        super.onCreate(bundle);
        if (bundle != null) {
            this.ˏॱ = bundle.getBoolean("has_start_selected", false);
        }
        if (this.ˏॱ) {
            finish();
            return;
        }
        View view = new View(this);
        view.setAlpha(0.0f);
        setContentView(view);
        getWindow().setBackgroundDrawableResource(c.ˊ);
        SafeIntent safeIntent = new SafeIntent(getIntent());
        this.ॱˊ = safeIntent.getIntExtra("oper_type", 1);
        this.ˋॱ = safeIntent.getStringExtra("callbackid");
        if (dof.ॱ(this.ˋॱ)) {
            azh.ˏ.ˊ("WebViewTransferActivity", "error no callbackID");
            finish();
        } else if (this.ॱˊ == 1) {
            this.ˊॱ = safeIntent.getBooleanExtra("choosefile_single", true);
            ᐝ();
        } else {
            finish();
        }
    }

    private void ᐝ() {
        fjb ˎ = fho.ˏ().ˋ("Media").ˎ("MediaSelect");
        IMediaSelectProtocol iMediaSelectProtocol = (IMediaSelectProtocol) ˎ.ˊ();
        iMediaSelectProtocol.setMediaType("image");
        iMediaSelectProtocol.setMimeTyes(new String[]{"image/jpeg", "image/jpg", "image/png"});
        if (this.ˊॱ) {
            iMediaSelectProtocol.setMaxSelectSize(1);
        }
        this.ˏॱ = true;
        fiu.ˊ().ॱ((Context) this, ˎ, new fjc<IMediaSelectResult>(this) {
            final /* synthetic */ WebViewTransferActivity ˊ;

            {
                this.ˊ = r1;
            }

            public /* synthetic */ void ˎ(int i, Object obj) {
                ˊ(i, (IMediaSelectResult) obj);
            }

            public void ˊ(int i, IMediaSelectResult iMediaSelectResult) {
                List list = null;
                if (i == -1 && iMediaSelectResult != null) {
                    list = iMediaSelectResult.getSelectedMedias();
                }
                baf.ॱ().ˏ(1000, i, this.ˊ.ˋॱ, list);
                this.ˊ.finish();
            }
        });
    }
}
